package com.ggkt.common.utils.dao;
import java.io.Serializable;

@SuppressWarnings("serial")
public class Query implements Serializable {
	
	/** 每页多少数据，用于分页 */
	protected Integer pageSize = 10;
	
	/** 取数据起始行，用于分页 */
	protected Integer offset = 0;

	/** 当前页，用于分页 */
	protected Integer currentPage = 1;
	
	protected Integer order;
	
	protected String orderby;
	
	public Integer getOffsetByCurrentPage() {
	    return this.getPageSize() * (this.getCurrentPage() - 1);
	}

    public Integer getPageSize() {
        if (this.pageSize <= 0) {
            this.pageSize = 10;
        } 
        else if (this.pageSize > 100) {
            this.pageSize = 100;
        }
        return this.pageSize;
    }
    
    public Integer getCurrentPage() {
        if (currentPage == null || currentPage <= 0) {
            currentPage = 1;
        }
        return currentPage;
    }

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getOffset() {
		return offset;
	}

	public void setOffset(Integer offset) {
		this.offset = offset;
	}

	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}

	public Integer getOrder() {
		return order;
	}

	public void setOrder(Integer order) {
		this.order = order;
	}

	public String getOrderby() {
		return orderby;
	}

	public void setOrderby(String orderby) {
		this.orderby = orderby;
	}

}